package com.xhwl.logistics.aop;

import com.xhwl.logistics.bo.cent.VehicleIntegratedConfigBO;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@Aspect
public class VehicleAspectForStatisticsToBi {

    @Pointcut("execution(public void com.xhwl.logistics.strategy.impl.VehicleParkingLotHaiKangHandlerImpl.statisticsToBi(..))")
    private void pointcutForHaiKangStatisticsToBi() {}

    @Before("pointcutForHaiKangStatisticsToBi() && args(vehicleIntegratedConfigBO,..)")
    public void before(VehicleIntegratedConfigBO vehicleIntegratedConfigBO) {
        log.info("HaiKang statistics to bi start!project Id: {}", vehicleIntegratedConfigBO.getVehicleSystemInfoBO().getProjectId());
    }

    @AfterThrowing(value = "pointcutForHaiKangStatisticsToBi() && args(vehicleIntegratedConfigBO,..)", throwing = "exception")
    public void afterThrow(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, Exception exception) {
        log.error("HaiKang statistics happen exception!exception message: {}, project id: {}", exception.getMessage(), vehicleIntegratedConfigBO.getVehicleSystemInfoBO().getProjectId());
    }

    @After("pointcutForHaiKangStatisticsToBi() && args(vehicleIntegratedConfigBO,..)")
    public void after(VehicleIntegratedConfigBO vehicleIntegratedConfigBO) {
        log.info("HaiKang statistics to bi end!project Id: {}", vehicleIntegratedConfigBO.getVehicleSystemInfoBO().getProjectId());
    }

}
